﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using Hotpot.Extensions;
using Hotpot.Log.Appender;

/*
**创建人：罗嗣宝
**创建时间：2009/9/8 17:14:38
**文件描述：HotpotLogger类的作用描述
**修改人：
**修改时间：
**修改描述：
**/
namespace Hotpot.Log
{
    ///<summary>
    /// 日志记录
    ///</summary>
    public static class HotpotLogger
    {

        private static ILog GetLog(Assembly assembly)
        {
            ILog log = LogManager.GetLogger(assembly.FullName);
            Config.XmlConfigurator.Configure();
            return log;
        }

        #region Info

        /// <summary>
        /// 记录日志信息
        /// </summary>
        /// <param name="message"></param>
        public static void Info(this object message)
        {
            GetLog(Assembly.GetCallingAssembly()).Info(message);
        }

        /// <summary>
        /// 记录日志信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public static void Info(this object message, Exception exception)
        {
            GetLog(Assembly.GetCallingAssembly()).Info(message, exception);
        }

        /// <summary>
        /// 记录日志信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public static void InfoFormat(this string format, params object[] args)
        {
            GetLog(Assembly.GetCallingAssembly()).InfoFormat(format, args);
        }

        /// <summary>
        /// 记录日志信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="provider"></param>
        /// <param name="args"></param>
        public static void InfoFormat(this string format, IFormatProvider provider, params object[] args)
        {
            GetLog(Assembly.GetCallingAssembly()).InfoFormat(provider, format, args);
        }

        #endregion

        #region Debug

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="message"></param>
        public static void Debug(this object message)
        {
            Config.XmlConfigurator.Configure();
            GetLog(Assembly.GetCallingAssembly()).Debug(message);
        }

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="o"></param>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public static void Debug(this object message, Exception exception)
        {
            GetLog(Assembly.GetCallingAssembly()).Debug(message, exception);
        }

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public static void DebugFormat(this string format, params object[] args)
        {
            GetLog(Assembly.GetCallingAssembly()).DebugFormat(format, args);
        }

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="provider"></param>
        /// <param name="args"></param>
        public static void DebugFormat(this string format, IFormatProvider provider, params object[] args)
        {
            GetLog(Assembly.GetCallingAssembly()).DebugFormat(provider, format, args);
        }

        #endregion

        #region Error

        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="message"></param>
        public static void Error(this object message)
        {
            GetLog(Assembly.GetCallingAssembly()).Error(message);
        }

        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="exception"></param>
        public static void Error(this object message, Exception exception)
        {
            GetLog(Assembly.GetCallingAssembly()).Error(message, exception);
        }

        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public static void ErrorFormat(this string format, params object[] args)
        {
            GetLog(Assembly.GetCallingAssembly()).ErrorFormat(format, args);
        }

        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public static void ErrorFormat(this string format, IFormatProvider provider, params object[] args)
        {
            GetLog(Assembly.GetCallingAssembly()).ErrorFormat(provider, format, args);
        }

        #endregion

    }
}
